<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>



<f:subview id="departments">
	<a4j:loadBundle var="msg" basename="messages_#{localManager.local}"></a4j:loadBundle>
	<h:form style="overflow:auto">
		<script type="text/javascript">
			var row;
		</script>
		<a4j:region>
			<rich:dataTable value="#{departmentsManager.dataList}" var="dataItem"
				reRender="ds"
				id="departmentsList" onRowContextMenu="row=this; alert(this);"
				onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
				onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
				cellpadding="0" cellspacing="0" border="0" rows="20">

				<f:facet name="header">
					<h:outputText value="#{msg['kurier.oddzialy.oddzialy']}" />
				</f:facet>

				<rich:column width="25" sortBy="#{dataItem.idOddzialu}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.oddzialy.id']}"/>
					</f:facet>
					<h:outputText value="#{dataItem.idOddzialu}" />
				</rich:column>

				<rich:column width="25" sortBy="#{dataItem.nazwa}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.oddzialy.nazwa']}" />
					</f:facet>
					<h:outputText value="#{dataItem.nazwa}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.adres}}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.oddzialy.adres']}" />
					</f:facet>
					<h:outputText value="#{dataItem.adres}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.telefon}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.oddzialy.telefon']}" />
					</f:facet>
					<h:outputText value="#{dataItem.telefon}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.longa}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.oddzialy.pozycjaX']}" />
					</f:facet>
					<h:outputText id="imieOutput" value="#{dataItem.longa}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.lat}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.oddzialy.pozycjaY']}" />
					</f:facet>
					<h:outputText value="#{dataItem.lat}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.glowny}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.oddzialy.glowny']}" />
					</f:facet>

					<h:outputText value="#{dataItem.glowny}" />

				</rich:column>

				<rich:column sortBy="#{dataItem.nadrzedny}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.oddzialy.nadrzedny']}" />
					</f:facet>
					<h:outputText value="#{dataItem.nadrzedny}" />
				</rich:column>


				<rich:column sortBy="#{dataItem.kod1}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.oddzialy.kod1']}"  />
					</f:facet>
					<h:outputText value="#{dataItem.kod1}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.kod2}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.oddzialy.kod2']}" />
					</f:facet>
					<h:outputText value="#{dataItem.kod2}" />
				</rich:column>

				<rich:column>
					<a4j:commandLink ajaxSingle="true" id="editlink"
						action="#{departmentsManager.prepareEditData}"
						oncomplete="#{rich:component('editMPdepartments')}.show()">
						<h:graphicImage value="/images/edit.gif" style="border:0" />
						<f:setPropertyActionListener value="#{dataItem}"
							target="#{departmentsManager.editedData}" />
						
					</a4j:commandLink>
					<rich:toolTip for="editlink" value="#{msg['kurier.zlec.edit']}" />

					<a4j:commandLink ajaxSingle="true" id="deleteLink"
						oncomplete="#{rich:component('deleteMPdepartments')}.show()">
						<h:graphicImage value="/images/delete.gif" style="border:0" />
						<f:setPropertyActionListener value="#{dataItem}"
							target="#{departmentsManager.editedData}" />
						
					</a4j:commandLink>
					<rich:toolTip for="deleteLink" value="#{msg['kurier.zlec.usun']}" />
				</rich:column>

				<f:facet name="footer">
					<rich:datascroller id="ds" align="center" for="departmentsList"
					 maxPages="20" />
				</f:facet>
			</rich:dataTable>
			<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.dodaj']}" 
				action="#{departmentsManager.prepareAddData}"
				reRender="departmentsList"
				oncomplete="#{rich:component('addMPdepartments')}.show()">
			</a4j:commandButton>
			<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.odswierz']}" 
				action="#{departmentsManager.refreshData}"
				reRender=" departmentsList">
			</a4j:commandButton>
	 <rich:messages id="mymessages"  globalOnly="true"  style="color:red"/>
		</a4j:region>
		</h:form>


		<rich:modalPanel id="editMPdepartments" domElementAttachment="parent"
			autosized="true" width="500" height="350">

			<f:facet name="header">
				<h:outputText id="editLabel" value="#{msg['kurier.zlec.edit']}" ></h:outputText>
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/images/close2.png" styleClass="hidelink"
						id="hidelink" />
					<rich:componentControl for="editMPdepartments" attachTo="hidelink"
						operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:form>
				<a4j:outputPanel ajaxRendered="true">
					<h:panelGrid columns="3" border="0">


						<h:column>

							<h:outputLabel for="nazwa" value="#{msg['kurier.oddzialy.nazwa']}:" />
						</h:column>
						<h:column>

							<h:inputText size="35" id="nazwa"
								value="#{departmentsManager.editedData.nazwa}" immediate="true"
								required="true" maxlength="70" />

						</h:column>
						<h:column>
							<h:message style="color:red" for="nazwa" />
						</h:column>

						<h:column>
							<h:outputLabel for="adres" value="#{msg['kurier.oddzialy.adres']}:"/>
						</h:column>
						<h:column>
							<h:inputText size="35" id="adres"
								value="#{departmentsManager.editedData.adres}" immediate="true"
								required="true" maxlength="120" />
						</h:column>
						<h:column>
							<h:message style="color:red" for="adres" />
						</h:column>


						<h:column>
							<h:outputLabel for="telefon" value="#{msg['kurier.oddzialy.telefon']}:" />
						</h:column>
						<h:column>
							<h:inputText size="35" id="telefon"
								value="#{departmentsManager.editedData.telefon}"
								immediate="true" required="true" />
						</h:column>
						<h:column>
							<h:message style="color:red" for="telefon" />
						</h:column>



						<h:column>
							<h:outputLabel for="longa" value="#{msg['kurier.oddzialy.pozycjaX']}:"/>
						</h:column>
						<h:column>
							<h:inputText size="35" id="longa"
								value="#{departmentsManager.editedData.longa}" immediate="true"
								required="true" />
						</h:column>
						<h:column>
							<h:message style="color:red" for="longa" />
						</h:column>

						<h:column>
							<h:outputLabel for="lat" value="#{msg['kurier.oddzialy.pozycjaY']}:"/>
						</h:column>
						<h:column>
							<h:inputText size="35" id="lat"
								value="#{departmentsManager.editedData.lat}" immediate="true"
								required="true" />
						</h:column>
						<h:column>
							<h:message style="color:red" for="lat" />
						</h:column>

						<h:column>
							<h:outputLabel for="typ" value="#{msg['kurier.oddzialy.glowny']}:" />
						</h:column>
						<h:column>
							<h:selectOneMenu id="typ"
								value="#{departmentsManager.editedData.glowny}" immediate="true">
								<f:selectItems value="#{departmentsManager.glownyList}" />
								<a4j:support event="onchange"
									action="#{departmentsManager.changedGlowny}"
									reRender="nadrzedny , kod1 , kod2">
								</a4j:support>
							</h:selectOneMenu>

							<%-- <h:inputText id="typ" value="#{departmentsManager.editedData.glowny}"
								immediate="true" required="true" /> --%>
						</h:column>
						<h:column>
							<h:message style="color:red" for="typ" />
						</h:column>

						<h:column>
							<h:outputLabel for="nadrzedny" value="#{msg['kurier.oddzialy.nadrzedny']}:"/>
						</h:column>
						<h:column>
							<h:selectOneMenu id="nadrzedny"
								disabled="#{departmentsManager.disnadrz}"
								value="#{departmentsManager.editedData.nadrzedny}"
								immediate="true">
								<f:selectItems value="#{departmentsManager.oddzialy}" />

							</h:selectOneMenu>

							<%-- <h:inputText id="nadrzedny" value="#{departmentsManager.editedData.nadrzedny}"
								immediate="true" required="true" /> --%>
						</h:column>
						<h:column>
							<h:message style="color:red" for="nadrzedny" />
						</h:column>

						<h:column>
							<h:outputLabel for="kod1" value="#{msg['kurier.oddzialy.kod1']}:"  />
						</h:column>
						<h:column>
							<h:inputText size="35" id="kod1"
								value="#{departmentsManager.editedData.kod1}" immediate="true"
								disabled="#{departmentsManager.dispozycja}"  />
						</h:column>
						<h:column>
							<h:message style="color:red" for="kod1" />
						</h:column>

						<h:column>
							<h:outputLabel for="kod2" value="#{msg['kurier.oddzialy.kod2']}:"  />
						</h:column>
						<h:column>
							<h:inputText size="35" id="kod2"
								value="#{departmentsManager.editedData.kod2}"
								disabled="#{departmentsManager.dispozycja}" immediate="true"
								/>
						</h:column>
						<h:column>
							<h:message style="color:red" for="kod2" />
						</h:column>

						<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.edit.zapisz']}" 
							action="#{departmentsManager.editData}"
							reRender=" departmentsList"
							oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editMPdepartments')}.hide();}">
						</a4j:commandButton>
						<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.edit.anuluj']}" 
							onclick="#{rich:component('editMPdepartments')}.hide(); return false;" />

					</h:panelGrid>
						 <rich:messages id="mymessages"  globalOnly="true"  style="color:red"/>
				</a4j:outputPanel>
			</h:form>

		</rich:modalPanel>

		<rich:modalPanel id="addMPdepartments" domElementAttachment="parent"
			autosized="true" width="500" height="350">
			<f:facet name="header">
				<h:outputText id="addLabel" value="#{msg['kurier.zlec.dodaj']}" ></h:outputText>
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/images/close2.png" styleClass="hidelink"
						id="hidelink1" />
					<rich:componentControl for="addMPdepartments" attachTo="hidelink1"
						operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:form>
				<a4j:outputPanel ajaxRendered="true">
					<h:panelGrid columns="3" border="0">
					
							<h:column>

							<h:outputLabel for="nazwa" value="#{msg['kurier.oddzialy.nazwa']}:" />
						</h:column>
						<h:column>

							<h:inputText size="35" id="nazwa"
								value="#{departmentsManager.newData.nazwa}" 
								required="true" maxlength="70" />

						</h:column>
						<h:column>
							<h:message style="color:red" for="nazwa" />
						</h:column>

						<h:column>
							<h:outputLabel for="adres" value="#{msg['kurier.oddzialy.adres']}:"/>
						</h:column>
						<h:column>
							<h:inputText size="35" id="adres"
								value="#{departmentsManager.newData.adres}" 
								required="true" maxlength="120" />
						</h:column>
						<h:column>
							<h:message style="color:red" for="adres" />
						</h:column>


						<h:column>
							<h:outputLabel for="telefon" value="#{msg['kurier.oddzialy.telefon']}:" />
						</h:column>
						<h:column>
							<h:inputText size="35" id="telefon"
								value="#{departmentsManager.newData.telefon}"
								 required="true" />
						</h:column>
						<h:column>
							<h:message style="color:red" for="telefon" />
						</h:column>



						<h:column>
							<h:outputLabel for="longa" value="#{msg['kurier.oddzialy.pozycjaX']}:"/>
						</h:column>
						<h:column>
							<h:inputText size="35" id="longa"
								value="#{departmentsManager.newData.longa}" 
								required="true" />
						</h:column>
						<h:column>
							<h:message style="color:red" for="longa" />
						</h:column>

						<h:column>
							<h:outputLabel for="lat" value="#{msg['kurier.oddzialy.pozycjaY']}:"/>
						</h:column>
						<h:column>
							<h:inputText size="35" id="lat"
								value="#{departmentsManager.newData.lat}" 
								required="true" />
						</h:column>
						<h:column>
							<h:message style="color:red" for="lat" />
						</h:column>

						<h:column>
							<h:outputLabel for="typ" value="#{msg['kurier.oddzialy.glowny']}:" />
						</h:column>
						<h:column>
							<h:selectOneMenu id="typ"
								value="#{departmentsManager.newData.glowny}" immediate="true">
								<f:selectItems value="#{departmentsManager.glownyList}" />
								<a4j:support event="onchange" ajaxSingle="true"
									action="#{departmentsManager.changedGlowny2}"
									reRender="nadrzedny , kod1 , kod2">
								</a4j:support>
							</h:selectOneMenu>


							<%-- <h:inputText id="typ" value="#{departmentsManager.editedData.glowny}"
								immediate="true" required="true" /> --%>
						</h:column>	
							
						<h:column>
							<h:message style="color:red" for="typ" />
						</h:column>

						<h:column>
							<h:outputLabel for="nadrzedny" value="#{msg['kurier.oddzialy.nadrzedny']}:"/>
						</h:column>
						<h:column>
							<h:selectOneMenu id="nadrzedny" 
								disabled="#{departmentsManager.disnadrz}"
								value="#{departmentsManager.newData.nadrzedny}"
								immediate="true">
								<f:selectItems value="#{departmentsManager.oddzialy}" />

							</h:selectOneMenu>

							<%-- <h:inputText id="nadrzedny" value="#{departmentsManager.newData.nadrzedny}"
								immediate="true" required="true" /> --%>
						</h:column>
						<h:column>
							<h:message style="color:red" for="nadrzedny" />
						</h:column>

						<h:column>
							<h:outputLabel for="kod1" value="#{msg['kurier.oddzialy.kod1']}:"  />
						</h:column>
						<h:column>
							<h:inputText size="35" id="kod1"
								value="#{departmentsManager.newData.kod1}" immediate="true"
								disabled="#{departmentsManager.dispozycja}"  />
						</h:column>
						<h:column>
							<h:message style="color:red" for="kod1" />
						</h:column>

						<h:column>
							<h:outputLabel for="kod2" value="#{msg['kurier.oddzialy.kod2']}:"  />
						</h:column>
						<h:column>
							<h:inputText size="35" id="kod2"
								value="#{departmentsManager.newData.kod2}"
								disabled="#{departmentsManager.dispozycja}" immediate="true"
								/>
						</h:column>
						<h:column>
							<h:message style="color:red" for="kod2" />
						</h:column>

						<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.edit.zapisz']}"
							action="#{departmentsManager.addData}" reRender="departmentsList"  
							oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('addMPdepartments')}.hide();}"/>
						<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.edit.anuluj']}"
							onclick="#{rich:component('addMPdepartments')}.hide(); return false;" />
					</h:panelGrid>
						 <rich:messages id="mymessages"  globalOnly="true"  style="color:red"/>
				</a4j:outputPanel>
			</h:form>
		</rich:modalPanel>

		<rich:modalPanel id="deleteMPdepartments" autosized="true" width="200">
			<f:facet name="header">
				<h:outputText value="#{msg['kurier.zlec.usun']}"
					style="padding-right:15px;" />
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/images/close2.png" styleClass="hidelink"
						id="hidelink2" />
					<rich:componentControl for="deleteMPdepartments"
						attachTo="hidelink2" operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:form>
				<table width="100%">
					<tbody>
						<tr>
							<td align="center" width="50%"><a4j:commandButton styleClass="RFbutton"
									value="#{msg['kurier.zlec.tak']}" ajaxSingle="true"
									action="#{departmentsManager.deleteData}"
									oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('deleteMPdepartments')}.hide();}"
									reRender="departmentsList" />
							</td>
							<td align="center" width="50%"><a4j:commandButton styleClass="RFbutton"
									value="#{msg['kurier.zlec.edit.anuluj']}"
									onclick="#{rich:component('deleteMPdepartments')}.hide();return false;" />
							</td>
						</tr>
					</tbody>
				</table>
					 <rich:messages id="mymessages"  globalOnly="true"  style="color:red"/>
			</h:form>
		</rich:modalPanel>
		<a4j:status onstart="#{rich:component('wait')}.show()"
			onstop="#{rich:component('wait')}.hide()" />
		<rich:modalPanel id="wait" autosized="true" width="200" height="120"
			moveable="false" resizeable="false">
			<f:facet name="header">
				<h:outputText value="Processing" />
			</f:facet>
			<h:outputText value="Wait Please..." />
		</rich:modalPanel>




</f:subview>
